<!doctype html>
<html>
<head>
    <title>{$backend_name}-{$code_name}</title>
    <meta name="description" content="">
    {include file="public/head"}
</head>
<body>
<!--header-->
{include file="public/header"}
<div class="tpl-page-container tpl-page-header-fixed">
    <!--menu-->
    {include file="public/menu"}
    <!--html body-->
    <div class="tpl-content-wrapper">
        <!--nav-->
        <div class="tpl-content-page-title">
            {$code_name}
        </div>
        <ol class="am-breadcrumb">
            <li><a href="{:url('index/index')}" class="am-icon-home">首页</a></li>
            <li><a href="{:url('active/index')}">活动</a></li>
            <li class="am-active">{$code_name}</li>
        </ol>
        <!--content-->
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    <span class="am-icon-code"></span> {$code_name}列表-活动-{$active_name}
                </div>
            </div>
            <div class="tpl-block">
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-md-12">
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <div style="float: left;">
                                    按用户:
                                    <select name="search_type" class="span1">
                                        <option value="nickname">昵称</option>
                                        <option value="mobile" {eq name="$search_type" value="mobile"}selected{/eq}>手机</option>
                                        <option value="contestant_number" {eq name="$search_type" value="contestant_number"}selected{/eq}>编号</option>
                                    </select>
                                    <input type="text" name="keywords" value="{$keywords}" style="border:1px solid rgb(169, 169, 169);"/>
                                    按:
                                    <select name="order_field" class="span1">
                                        <option value="create_time">时间</option>
                                        <option value="support" {eq name="$order_field" value="support"}selected{/eq}>支持</option>
                                    </select>
                                    <select name="order_type" class="span1">
                                        <option value="desc">降序</option>
                                        <option value="asc" {eq name="$order_type" value="asc"}selected{/eq}>升序</option>
                                    </select>

                                    状态为:
                                    <select name="search_status" class="span1">
                                        <option value="">全部</option>
                                        <option value="0" {heq name="$search_status" value="0"}selected{/heq}>未审核</option>
                                        <option value="1" {eq name="$search_status" value="1"}selected{/eq}>已通过</option>
                                        <option value="2" {eq name="$search_status" value="2"}selected{/eq}>未通过</option>
                                    </select>

                                    渠道为:
                                    <select name="search_channel" class="span1">
                                        <option value="all">全部</option>
                                        {foreach $channels as $key=>$value}
                                        <option value="{$key}" {eq name="$search_channel" value="$key"}selected{/eq}>{$value}</option>
                                        {/foreach}
                                    </select>
                                </div>
                                <div style="float: left;margin-left: 10px;">
                                    <a href="{:url($code.'/index',['active_id'=>$active_id])}" class="am-btn am-btn-default am-btn-primary search_btn">搜索</a>
                                    <!-- <a href="{:url($code.'/to_excel',['active_id'=>$active_id])}" class="am-btn am-btn-default am-btn-primary">导出表格</a> -->
                                    {if condition="$is_open"}
                                    <a href="{:url($code.'/get_new',['active_id'=>$active_id])}" class="am-btn am-btn-default am-btn-success"><span
                                            class="am-icon-plus"></span> 后台添加
                                    </a>
                                    {/if}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="am-g" style="margin-top:20px;">
                    <div class="am-u-sm-12">
                        <form class="am-form">
                            <table class="am-table am-table-striped am-table-hover table-main">
                                <thead>
                                <tr>
                                    <!--<th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>-->
                                    <th>#</th>
                                    <th>姓名</th>
                                    <th>手机</th>
                                    <th>状态</th>
                                    <th>支持数</th>
                                    <th>报名渠道</th>
                                    <th>报名时间</th>
                                    <th>修改时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach $list as $vo}
                                <tr>
                                    <!--<td><input type="checkbox"></td>-->
                                    <td>{$vo.contestant_number}</td>
                                    <td title="{$vo.user_id}">
                                        {$vo.nickname?:'(未获取)'}
                                        {switch name="$vo.sign_pass_way"}
                                        {case value="wx"}<span class="am-badge am-badge-success am-radius">{$pass_way[$vo.sign_pass_way]}</span>{/case}
                                        {case value="yqsbz"}
                                        {if condition='$vo.site'}
                                        <span class="am-badge am-badge-warning  am-radius">{$sites[$vo.site]}</span>
                                        {else/}
                                        <span class="am-badge am-badge-warning  am-radius">{$pass_way[$vo.sign_pass_way]}</span>
                                        {/if}
                                        {/case}
                                        {case value="backend"}<span class="am-badge am-badge-primary  am-radius">{$pass_way[$vo.sign_pass_way]}</span>{/case}
                                        {default/}<span class="am-badge am-radius">未知</span>
                                        {/switch}
                                    </td>
                                    <td>{$vo.mobile}</td>
                                    <td class="status_td">
                                        {switch name="vo.status" }
                                        {case value="1"}<span class="am-badge am-badge-success am-radius">已通过</span>{/case}
                                        {case value="0"}<span class="am-badge am-radius">未审核</span>{/case}
                                        {case value="2"}<span class="am-badge am-badge-danger am-radius">未通过</span>{/case}
                                        {/switch}
                                    </td>
                                    <td>{$vo.support}</td>
                                    <td>{$vo.channel?$channels[$vo.channel]:'乐清上班族'}</td>
                                    <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                                    <td>{$vo.update_time|date='Y-m-d H:i:s',###}</td>
                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <a class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                                   href="{:url('vote_list/index',['active_id'=>$vo.active_id,'participant_id'=>$vo.user_id])}">
                                                    <span class="am-icon-list"></span> 投票详情
                                                </a>
                                                <a class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                                   href="{:url($code.'/get_edit',['id'=>$vo.id,'active_id'=>$vo.active_id])}">
                                                    <span class="am-icon-pencil-square-o"></span> 编辑
                                                </a>
                                                <a class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                                   href="{:url('report/index',['active_id'=>$vo.active_id,'participant_id'=>$vo.user_id])}">
                                                    <span class="am-icon-area-chart"></span> 报表
                                                </a>
                                                {if condition="$is_open"}
                                                {eq name="vo.status" value="1"}
                                                <a class="am-btn am-btn-default am-btn-xs am-text-secondary cancel_btn"
                                                   href="{:url('cancel',['id'=>$vo.id])}">
                                                    <span class="am-icon-minus-circle"></span> 禁止
                                                </a>
                                                {/eq}
                                                {/if}
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                                </tbody>
                            </table>
                            <div class="am-cf">
                                <div class="am-fr">
                                    {$page}
                                </div>
                            </div>
                            <hr>

                        </form>
                    </div>
                </div>
            </div>
            <div class="tpl-alert"></div>
        </div>
    </div>
</div>
<!--js-->
{include file="public/js"}
<script type="text/javascript">
    $('.am-icon-search').click(function(){
        var keywords = $('input[name=keywords]').val();
        window.location.href = '{:url($code."/index",["active_id"=>$active_id])}?keywords='+keywords;
    });

    $('.cancel_btn').click(function(){
        var _this = $(this);
        if(confirm('确定要禁用么？')){
            var url = _this.attr('href');
            $.post(url,{data:1},function(data){
                alert(data.message);
                if(data.code == 0){
                    _this.parents('tr:eq(0)').children('.status_td').html('<span style="color:red">未通过</span>');
                    _this.remove();
                }
            },'json')
        }
        return false;
    });

    $('.search_btn').click(function(){
        var active_id = $('select[name=active_id]').val();
        var url = $(this).attr('href');
        if(active_id){
            location.href = url+'?active_id='+active_id;
        }else{
            var search_type = $('select[name=search_type]').val();
            var order_type = $('select[name=order_type]').val();
            var order_field = $('select[name=order_field]').val();
            var search_status = $('select[name=search_status]').val();
            var search_channel = $('select[name=search_channel]').val();
            var keywords = $('input[name=keywords]').val();
            location.href = url+'?active_id={$active_id}&search_type='+search_type+'&keywords=' +
                keywords+'&order_field='+order_field+'&order_type='+order_type+'&search_status='+search_status+'&search_channel='+search_channel;
        }
        return false;
    });

</script>
</body>
</html>